<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            name
            gender
            constructor(name, gender) {
                this.name = name
                this.gender = gender
            }
            sleep() {
                return `${this.name}休息中...`
            }
        }
        //继承父类
        class Dengrui extends Person {
            web
            constructor(name, gender, web) {
                //继承父类属性
                super(name, gender)
                this.web = web
            }
            eat() {
                return `${this.name}吃零食`
            }
        }
        let dengrui = new Dengrui("dengrui", "男", "dengruicode.com")
        console.log(dengrui.web)
        console.log(dengrui.eat())
        console.log(dengrui.sleep())
    </script>
</body>

</html>